package com.hspedu.Homework;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class MapExercise {
    public static void main(String[] args) {
        HashMap hashMap = new HashMap();
        Employee xiaoming = new Employee("小明", 12000, 2345);
        Employee daming = new Employee("大明", 19000, 2445);
        Employee lihua = new Employee("李华", 20000, 2545);

        hashMap.put(xiaoming.getId(),xiaoming);
        hashMap.put(daming.getId(),daming);
        hashMap.put(lihua.getId(),lihua);

        Set set = hashMap.keySet();
        Iterator iterator = set.iterator();
        while (iterator.hasNext()){
                Object next = iterator.next();
                Employee emp=(Employee)hashMap.get(next);
                if(emp.getSalary()>18000){
                    System.out.println(emp.getName());
            }
        }

        System.out.println("===========");
        for (Object key : set) {
            Employee employee = (Employee)hashMap.get(key);
            if(employee.getSalary()>18000){
                System.out.println((employee.getName())); }

        }
    }
}

class Employee{
    private String name;
    private double salary;
    private int id;

    public Employee(String name, double salary, int id) {
        this.name = name;
        this.salary = salary;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
}